package com.hskn.hss.module.cases.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * <p>
 *
 * </p>
 *
 * @author hskn
 * @since 2021-05-18
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class CasesTable implements Serializable {

    private static final long serialVersionUID = 1L;
    /**
     * 开始时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField(exist = false)
    private Date startDate;
    /**
     * 结束时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField(exist = false)
    private Date endDate;
    /**
     * 机构类型
     */
    @TableField(exist = false)
    private String orgType;
    /**
     * 提交人id
     */
    @TableField(exist = false)
    private String createUid;
    /**
     * 提交人姓名
     */
    private String createName;
    /**
     * 提交人部门id
     */
    private String createDeptId;
    /**
     * 提交人部门名称
     */
    private String createDeptName;
    /**
     * 责任人id
     */
    private String personId;
    /**
     * 责任人姓名
     */
    private String personName;
    /**
     * 负责人的名字
     */
    @TableField(exist = false)
    private String userName;
    /**
     * 合计事件数
     */
    @TableField(exist = false)
    private Integer allCount = 0;
    /**
     * 已结案数量
     */
    private Integer closedCount = 0;
    /**
     * 未结案数量
     */
    private Integer openCount = 0;
    /**
     * 道路不洁件数 字段复用未完成件数 实际处理件数
     */
    @TableField(exist = false)
    private Integer dlbjCount = 0;
    /**
     * 暴露垃圾件数 及时处理件数
     */
    @TableField(exist = false)
    private Integer blljCount = 0;
    /**
     * 垃圾污染件数 逾期处理件数
     */
    @TableField(exist = false)
    private Integer ljwrCount = 0;
    /**
     * 绿地脏乱
     */
    @TableField(exist = false)
    private Integer ldzlCount = 0;
    /**
     * 积存垃圾渣土
     */
    @TableField(exist = false)
    private Integer jcljztCount = 0;
    /**
     * 道路遗撒
     */
    @TableField(exist = false)
    private Integer dlysCount = 0;
    /**
     * 水域不洁
     */
    @TableField(exist = false)
    private Integer sybjCount = 0;
    /**
     * 油烟污染
     */
    @TableField(exist = false)
    private Integer yywrCount = 0;
    /**
     * 动物尸体清理
     */
    @TableField(exist = false)
    private Integer dwstqlCount = 0;
    /**
     * 其他类型件数
     */
    @TableField(exist = false)
    private Integer qitaCount = 0;
    /**
     * 实际处理率
     */
    @TableField(exist = false)
    private String processingRate;
    /**
     * 事件处理率
     */
    @TableField(exist = false)
    private String timelyRate;
    /**
     * 事件处理率
     */
    @TableField(exist = false)
    private String overdueRate;

    /**
     *  所属部门名称
     */
    private String depName;

    private String caseIssueChildName;

    public Integer getQitaCount() {
        return allCount -
                dlbjCount -
                blljCount -
                ljwrCount -
                ldzlCount -
                jcljztCount -
                dlysCount -
                sybjCount -
                yywrCount -
                dwstqlCount;
    }

    public String getProcessingRate() {
        BigDecimal number = new BigDecimal("100");
        if (allCount > 0) {
            number = new BigDecimal(dlbjCount.toString()).divide(new BigDecimal(allCount.toString()), 3, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(1);
        }
        return number.toString();
    }

    public String getTimelyRate() {
        BigDecimal number = new BigDecimal("100");
        if (allCount > 0) {
            number = new BigDecimal(blljCount.toString()).divide(new BigDecimal(allCount.toString()), 3, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(1);
        }
        return number.toString();
    }

    public String getOverdueRate() {
        BigDecimal number = new BigDecimal("100");
        if (allCount > 0) {
            number = new BigDecimal(ljwrCount.toString()).divide(new BigDecimal(allCount.toString()), 3, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(1);
        }
        return number.toString();
    }
}
